<template>
  <div style="width: 97%;margin: 0 auto">
    <div class="search">
      <div style="margin-left: 16px;margin-top: 10px;">
        <i class="el-icon-s-custom" ></i>病例查看
      </div>
      <div class="int">
        <el-form :model="queryParams"  ref="queryForm">
        <el-date-picker
          style="width: 252px;height: 30px!important;margin-left: 20px;margin-top: 20px"
          v-model="queryParams.createTime"
          size="small"
          type="daterange"
          range-separator=" "
          start-placeholder="创建日期"
          end-placeholder="">
        </el-date-picker>
        </el-form>
      </div>
      <div class="inquire">
        <el-button type="success" style="height: 30px;display: flex;align-items: center;float:left;margin-right: 20px"
        @click="search">
          <i  class="el-icon-search"></i>
          查询</el-button>
        <el-button style="height: 30px;display: flex;align-items: center;float:left;margin-right: 25px" @click="reset">
          <i  class="el-icon-refresh"></i>
          重置</el-button>
        <el-button style="height: 30px;display: flex;align-items: center;">
          <i  class="el-icon-refresh"></i>
          添加</el-button>
      </div>
    </div>
    <div class="list">
      <el-table
        :data="tableData.slice((currentPage-1)*pagesize,currentPage*pagesize)"
        stripe
        style="width: 100%"
        :row-class-name="tableRowClassName">
        <el-table-column
          prop="createTime"
          label="时间"
          align="center"
          width="220"
        >
        </el-table-column>
        <el-table-column
          align="center"
          width="880"
        >
        </el-table-column>
        <el-table-column
          prop="operate"
          align="center"
          label="操作">
          <template slot-scope="scope">
<!--            <i class="el-icon-edit-outline" style="margin-left: 20px; color: #1BD5B1; cursor:pointer;">修改</i>-->
            <i class="el-icon-zoom-in" style="margin-left: 20px;color: #4196ff; cursor:pointer;" @click="editshow(scope.$index,scope.row)">查看</i>
          <i class="el-icon-delete" style="margin-left: 20px; color: #FD3236; cursor:pointer;" @click="omit(scope.$index,scope.row)">删除</i>
          </template>
        </el-table-column>
      </el-table>
      <div style="position: absolute;right: 30px;bottom: 20px;">
<!--        <pagination-->
<!--          v-show="total>0"-->
<!--          :total="total"-->
<!--          :page.sync="queryParams.pageNum"-->
<!--          :limit.sync="queryParams.pageSize"-->
<!--          @pagination="Caselist"-->
<!--        />-->
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="queryParams.pageNum"
          :page-sizes="[3, 5, 10,15]"
          :page-size="queryParams.pagesize"
          layout=" prev, pager, next,sizes, jumper"
          :total="tableData.length">
        </el-pagination>
      </div>

    </div>
    <!--查看窗口-->
    <div class="check" v-show="look">
      <div style="width: 100%;height: 50px;background:  #eaeaea;;line-height: 50px">
        <div style="float:left;margin-left: 25px">病例信息</div>
        <div style="float:right;margin-right: 20px" @click="off">
          <i class="el-icon-close"></i>
        </div>
      </div>
      <div class="content">
        <div class="line">
          <div class="one">就诊日期</div>
          <div class="tow" v-html="Viewlist.createTime"></div>
        </div>
        <div class="line" style="background: #F8F8F8;">
          <div class="one">就诊医院</div>
          <div class="tow" v-html="Viewlist.visitHospital"></div>
        </div>
        <div class="line">
          <div class="one">就诊科室</div>
          <div class="tow" v-html="Viewlist.visitDepartment"></div>
        </div>
      <div class="line" style="background: #F8F8F8;">
          <div class="one">挂号证件</div>
        <div class="tow" v-html="Viewlist.certificateNo"></div>
        </div>
        <div class="line">
          <div class="one">医生职称</div>
          <div class="tow" v-html="Viewlist.doctorPosition"></div>
        </div>
        <div class="lines" style="background: #F8F8F8;">
          <div class="one">家族病史</div>
          <div class="tow" v-html="Viewlist.familyMedicalHistory"></div>
        </div>
        <div class="lines">
          <div class="one">个人病逝</div>
          <div class="tow" v-html="Viewlist.personalMedicalHistory"></div>
        </div>
        <div class="lines" style="background: #F8F8F8;">
          <div class="one">主诉</div>
          <div class="tow" v-html="Viewlist.chiefComplaint"></div>
        </div>
        <div class="lines">
          <div class="one">诊断</div>
          <div class="tow" v-html="Viewlist.diagnosis"></div>
        </div>
        <div class="lines" style="background: #F8F8F8;">
          <div class="one">处方</div>
          <div class="tow" v-html="Viewlist.prescription"></div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  import {Caselist,omit,examine} from "../../../api/Case/Case";
  import {importTemplate} from "../../../api/drug/drug";
  import {remove} from "../../../api/patiente/patiente";

  export default {
    name: 'PatientManagement',
    data () {
      return {
        look:false,
        // total:0,
        custIds:[],
        queryParams: {
          custId:'',
          pageNum: 1,
          pageSize: 12,
          createTime: undefined
        },
        time: '',
        patientgender: '',
        currentPage: 1,
        pagesize: 10,
        enable: true,
        labelPosition: 'right',
        options: [{
          value: '0',
          label: '男'
        }, {
          value: '1',
          label: '女'
        }],
        tableData: [],
        Viewlist:[{}]
      }
    },
    created(){
      this.Caselist()
    },
    methods: {
      // 查看
      editshow(index,row){
        this.look = true
        console.log(row.caId)
        examine({caId:row.caId}).then(res=>{
          // console.log('res',res.data.visitHospital)
          this.Viewlist = res.data
          console.log( this.Viewlist)
        }).catch(err=>{
          console.log(err)
        })
      },
      off(){
          this.look= false,
          this.Viewlist = [{}]
      },
      //删除
      omit(index,row){
        console.log(row)

        this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning',
          center: true
        }).then(() => {
            omit({ids:row.caId}).then(res=>{
            console.log(res)
            this.Caselist()
            this.$message({
              type: 'success',
              message: '删除成功!'
            });
          }).catch(err=>{
            console.log(err)
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          });
        });
      },
      //查询
      search(){
        this.queryParams.page = 1;
        console.log('查询')
        Caselist(this.addDateRange(this.queryParams)).then(res=>{
          console.log(res.rows)
          this.tableData = res.rows
        }).catch(err=>{
          console.log(err)
        })
      },
      //列表
      Caselist(){
        // let data = this.$router.custId
        // console.log('参数',data)
        let data = this.$route.query.id
        console.log('参数',data)
        Caselist({custId :data}).then(res=>{
          this.queryParams.custId = data;
            // Caselist({custId :'100140'}).then(res=>{
          console.log('病例查看列表',res.rows)
          this.tableData = res.rows
        }).catch(err=>{
          console.log('列表错误',err)
        })
      },
      handleSizeChange (val) {
        this.pagesize = val
        console.log(`每页 ${val} 条`)
      },
      handleCurrentChange (val) {
        this.currentPage = val
        console.log(`当前页: ${val}`)
      },
      // 重置
      reset () {
        this.Caselist()
        this.resetForm("queryForm");
        this.queryParams.createTime = ''
      },
      tableRowClassName ({ row, rowIndex }) {
        if (rowIndex === 1) {
          return 'warning-row'
        } else if (rowIndex === 3) {
          return 'success-row'
        }
        return ''
      }
    }
  }
</script>

<style scoped lang="scss">
  .check{
    width: 700px;
    height: 89.7%;
    background: #FFFFFF;
    box-shadow: 0px 0px 32px 0px rgba(97,97,97,0.1);
    border-radius: 8px;
    position: absolute;
    top: 0;
    bottom: 0;
    left: -10%;
    right:0 ;
    margin: auto;
    z-index: 10;
    overflow: hidden;
    .content{
      width: 80%;
      height: 84%;
      background: #FFFFFF;
      border: 1px solid #cdcccc;
      border-radius: 24px;
      margin: 0 auto;
      margin-top: 20px;
      overflow: hidden;

      .line{
        width: 100%;
        height: 40px;
        background: #ffffff;
        .one{
          float: left;
          width: 35%;
          height: 100%;
          line-height: 40px;
          border-right: 2px solid #eae9e9;
          text-align: center;
        }
        .tow{
          width: 65%;
          height: 40px;
          line-height: 40px;
          text-align: center;
        }
      }
      .lines{
        width: 100%;
        height: 91px;
        background: #ffffff;
        .one{
          float: left;
          width: 35%;
          height: 91px;
          line-height: 100px;
          border-right: 2px solid #eae9e9;
          text-align: center;
        }
        .tow{
          width: 65%;
          height: 91px;
          line-height: 100px;
          text-align: center;
        }
      }
    }
  }
  .submit{
    width: 80px;
    height: 30px;
    background: #009945;
    border-radius: 4px;
    color: #ffffff;
    text-align: center;
    line-height: 30px;
    font-size: 12px;
    float: left;
    cursor:pointer;
  }
  .cancel{
    width: 80px;
    float: left;
    height: 30px;
    border-radius: 4px;
    text-align: center;
    line-height: 30px;
    font-size: 12px;
    border: 1px solid #EEEEEE;
    margin-left: 20px;
    cursor:pointer;
  }
  .redact{
    width: 600px;
    height: 580px;
    background: #FFFFFF;
    box-shadow: 0px 0px 32px 0px rgba(97,97,97,0.1);
    border-radius: 8px;
    position:fixed;
    top: 50%;
    left: 50%;
    margin-left: -300px;
    margin-top: -285px;
    z-index: 10;
    .title{
      width: 100%;
      height: 40px;
      background: #e7e5e5;
      /*background:red;*/
      border-radius: 8px 8px 0px 0px;
    }
  }
  .search{
    width: 100%;
    height: 120px;
    background: #ffffff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0px 4px 20px 0px rgba(51,51,51,0.08);
    margin-top: 20px;
  }
  .list{
    width: 100%;
    height: 680px;
    background: #ffffff;
    box-shadow: 0px 4px 20px 0px rgba(51,51,51,0.08);
    border-radius: 8px;
    margin-top: 20px;
    position: relative;
    /*.el-table .warning-row {*/
    /*  background: #fdf5e6;*/
    /*}*/

    /*.el-table .success-row {*/
    /*  background: #f0f9eb;*/
    /*}*/
  }
  .int{
    width: 28%;
    float: left;
    input{
      padding: 0px 10px;
      width: 225px;
      height: 30px;
      background: #FFFFFF;
      border: 1px solid #E8E8E8;
      border-radius: 4px;
      margin-left: 20px;
      margin-top:20px;
    }
  }
  .inquire{
    width: 40%;
    height: 50px;
    float: left;
    margin-top: 20px;
  }

</style>

